#import "MailFromFile.h"
#import "StringStorage.h"
#import "FileName.h"
#include <sys/file.h>
#include <sys/types.h>
#include <sys/uio.h>

@implementation MailFromFile

-initForMUA: (const char *)anApp  andMTA: (const char *)aMailer
{
   [super initForMUA: anApp andMTA: aMailer];
   [mailFile setStringValue: "/tmp/.mail"];
   [mailFile mktemp];
   fp = fopen([mailFile stringValue], "a");
   if(!fp)
       NXLogError("Failed to open %s", [mailFile stringValue]);
   return self;
}

-free
{
   fclose(fp);
   unlink([mailFile stringValue]);
   return [super free];
}
   
- buildBody
{
   [super buildBody];

   if(!fp)
   {
      NXLogError("Failed to open %s", [mailFile stringValue]);
      return nil;
   }

   fwrite([body stringValue],1,[body strlen],fp);
   return self;
}


@end
